package com.yzt.zhuju.network.biz;

import com.alibaba.fastjson.JSONObject;
import com.yzt.zhuju.network.AresSubscriber;
import com.yzt.zhuju.network.NetLayer;
import com.yzt.zhuju.network.apiconfig.MineUrlConfig;
import com.yzt.zhuju.network.entity.mine.wallet.WalletConfigBean;

import rx.Observable;
import rx.Observer;

/**
 * author :
 * date   : 2022/12/6A
 * desc   :
 */
public class MineModule extends BaseModule {

    /**
     * 设置视频资费
     */
    public void setCallExpenses(String price, Observer observer) {
        JSONObject json = new JSONObject();
        json.put("price", price);
        json.put("type", 1);
        Observable observable = NetLayer.getInstance().getMineService().setCallExpenses(getRequestBody(json));
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_MINE_CALL_EXPENSES);
    }

    /**
     * 我的钱包/消费收入
     * 增加字段isRevenue 默认1-钱包 2-收益
     */
    public void wallet(Observer observer) {
        Observable observable = NetLayer.getInstance().getMineService().wallet();
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_WALLET);
    }

    /**
     * 我的钱包/消费收入
     * 增加字段isRevenue 默认1-钱包 2-收益
     */
    public void walletConfig(Observer observer) {
        Observable observable = NetLayer.getInstance().getMineService().walletConfig();
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_WALLET_CONFIG);
    }


    /**
     * 提现
     */
    public void withDraw(String amount, Observer observer) {
        JSONObject json = new JSONObject();
        json.put("amount", amount);
        Observable observable = NetLayer.getInstance().getMineService().withDraw(getRequestBody(json));
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_WALLET_WITHDRAW);
    }

    /**
     * 提现
     */
    public void walletList(int type, int current, int pageSize, Observer observer) {
        JSONObject json = new JSONObject();
        json.put("current", current);
        json.put("pageSize", pageSize);

        Observable observable;
        if (type == 1) {
            observable = NetLayer.getInstance().getMineService().walletCandy(getRequestBody(json));
            toSubscribe2Filter(observable, observer, MineUrlConfig.API_WALLET_CANDY);
        } else if (type == 2) {
            observable = NetLayer.getInstance().getMineService().walletIncome(getRequestBody(json));
            toSubscribe2Filter(observable, observer, MineUrlConfig.API_WALLET_INCOME);
        } else {
            observable = NetLayer.getInstance().getMineService().walletTrans(getRequestBody(json));
            toSubscribe2Filter(observable, observer, MineUrlConfig.API_WALLET_TRANS);
        }
    }

    /**
     * 订单列表
     */
    public void orderList(int type, int current, int pageSize, Observer observer) {
        JSONObject json = new JSONObject();
        json.put("current", current);
        json.put("pageSize", pageSize);
        json.put("orderStatus", type);
        Observable observable = NetLayer.getInstance().getMineService().orderList(getRequestBody(json));
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_ORDER_LIST);
    }

    /**
     * 订单详情
     */
    public void getOrderDetail(String orderNo, Observer observer) {
        JSONObject json = new JSONObject();
        json.put("orderNo", orderNo);
        Observable observable = NetLayer.getInstance().getMineService().getOrderDetail(getRequestBody(json));
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_ORDER_DETAIL);
    }

    /**
     * 上传图片
     */
    public void updateAlbum(String picUrl, Observer observer) {
        JSONObject json = new JSONObject();
        json.put("picUrl", picUrl);
        Observable observable = NetLayer.getInstance().getMineService().updateAlbum(getRequestBody(json));
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_UPDATE_ALBUM);
    }

    /**
     * 我的钱包/消费收入历史
     */
    public void walletList(String filterId, int assetsType, int page, int size, Observer observer) {
        Observable observable = NetLayer.getInstance().getMineService().walletList(filterId, assetsType, page, size);
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_WALLET_LIST);
    }

    /**
     * 我的钱包/消费筛选条件
     */
    public void getFilterList(int assetsType, Observer observer) {
        Observable observable = NetLayer.getInstance().getMineService().getFilterList(assetsType);
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_GET_FILTER_LIST);
    }

    /**
     * 消息群发
     */
    public void messageContent(String targetUids, String message, Observer observer) {
        JSONObject json = new JSONObject();
        json.put("targetUids", targetUids);
        json.put("message", message);
        Observable observable = NetLayer.getInstance().getMineService().messageContent(getRequestBody(json));
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_MESSAGE_CONTENT);
    }


    /**
     * 创建支付订单
     */
    public void createPayOrder(String productId, Observer observer) {
        JSONObject json = new JSONObject();
        json.put("packId", productId);
        json.put("payType", 1);
        Observable observable = NetLayer.getInstance().getMineService().googleNotify(getRequestBody(json));
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_PAYMENT_GOOGLE_NOTIFY);
    }

    /**
     * 获取充值列表
     */
    public void getPaymentList(Observer observer) {
        JSONObject json = new JSONObject();
        json.put("payType", 0);
        Observable observable = NetLayer.getInstance().getMineService().getPaymentList(getRequestBody(json));
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_PAYMENT_LIST);
    }

    /**
     * 修改视频接听状态
     *
     * @param type 0:设置离线,1:设置在线
     */
    public void setCallSwitch(int type, Observer observer) {
        JSONObject json = new JSONObject();
        json.put("type", type);
        Observable observable = NetLayer.getInstance().getMineService().setCallSwitch(getRequestBody(json));
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_MINE_CALL_ON_LINE);
    }

    /**
     * 获取聊天价格列表
     *
     * @param targetUid 查询目标
     */
    public void getCallExpensesList(String targetUid, Observer observer) {
        Observable observable = NetLayer.getInstance().getMineService().getCallExpensesList(targetUid);
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_GET_CALL_PRICE_LIST);
    }


    /**
     * 惩罚卡价格
     */
    public void punishPrice(Observer observer) {
        JSONObject json = new JSONObject();
        Observable observable = NetLayer.getInstance().getMineService().punishPrice(getRequestBody(json));
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_PUNISH_PRICE);
    }

    /**
     * 惩罚卡摇一摇
     */
    public void punishShark(String activityId,Observer observer) {
        JSONObject json = new JSONObject();
        json.put("activityId", activityId);
        Observable observable = NetLayer.getInstance().getMineService().punishShark(getRequestBody(json));
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_PUNISH_SHARK);
    }

    /**
     * 钱包详情
     */
    public void getWalletDetail(String id, Observer observer) {
        JSONObject json = new JSONObject();
        json.put("transactionsId", id);
        Observable observable = NetLayer.getInstance().getMineService().getWalletDetail(getRequestBody(json));
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_WALLET_DETAIL);
    }

    /**
     * 人脸核验（结束后需要轮询获取结果，得到结果后才跳转
     */
    public void userAuth(String name, String number, Observer observer) {
        JSONObject json = new JSONObject();
        json.put("realName", name);
        json.put("idCard", number);
        Observable observable = NetLayer.getInstance().getMineService().userAuth(getRequestBody(json));
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_USER_AUTH);
    }

    /**
     * 人脸核验（结束后需要轮询获取结果，得到结果后才跳转
     */
    public void getESignResult( Observer observer) {
        JSONObject json = new JSONObject();
//        json.put("realName", name);
//        json.put("idCard", number);
        Observable observable = NetLayer.getInstance().getMineService().getESignResult(getRequestBody(json));
        toSubscribe2Filter(observable, observer, MineUrlConfig.API_USER_AUTH_RESULT);
    }
}
